package com.ihg.hiex.admin.dao.account;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.user.Account;

/**
 * 
 * @author ZEAL
 *
 */
@Dao("hibernate")
public interface AccountDao {

    /**
     * @param email
     * @return
     */
    @Query("FROM Account WHERE disabled = false AND email = :email")
    Account loadByEmail(@Variable("email") String email);
    
    /**
     * 
     * @param authority
     * @return
     */
    @Query("SELECT COUNT(1) FROM Account WHERE disabled = false AND authority = :authority ")
    int count(@Variable("authority") String authority);
    
    /**
     * 
     * @param authority
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM Account WHERE disabled = false AND authority = :authority ")
    List<Account> list(@Variable("authority") String authority, @Variable("beginIndex")int beginIndex, @Variable("maxResult")int maxResult);
    
    /**
     * 
     * @param authority
     * @return
     */
    @Query("FROM Account WHERE disabled = false AND authority = :authority ")
    List<Account> list(@Variable("authority") String authority);
    
}
